<?php

    $notifications = 0;
	
	include_once "include/constants.php";
	
    try {
        $conn = new PDO('mysql:host='.DB_SERVER.';dbname='.DB_NAME, DB_USER, DB_PASS);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $stmt = $conn->prepare('select count(*) as cnt from notifications where active=1 and userid = ' . $session->userinfo['id']);
		$stmt->execute();
        
        $row = $stmt->fetch();
		if ($row['cnt'] > 0) $notifications = $row['cnt'];
    } catch(PDOException $e) {
        echo 'ERROR: ' . $e->getMessage();
    }
    
?>

<?php
    $hrefclass = array();
    $iconclass = array();
    $hrefclass['home'] = CURR_PAGE == "home" ? "active" : "";
    $iconclass['home'] = CURR_PAGE == "home" ? "icon-white" : "";
    $hrefclass['profile'] = CURR_PAGE == "profile" ? "active" : "";
    $iconclass['profile'] = CURR_PAGE == "profile" ? "icon-white" : "";
    $hrefclass['create'] = CURR_PAGE == "create" ? "active" : "";
    $iconclass['create'] = CURR_PAGE == "create" ? "icon-white" : "";
    $hrefclass['friends'] = CURR_PAGE == "friends" ? "active" : "";
    $iconclass['friends'] = CURR_PAGE == "friends" ? "icon-white" : "";
    $hrefclass['notifications'] = CURR_PAGE == "notifications" ? "active" : "";
    $iconclass['notifications'] = CURR_PAGE == "notifications" ? "icon-white" : "";
    $hrefclass['events'] = CURR_PAGE == "events" ? "active" : "";
    $iconclass['events'] = CURR_PAGE == "events" ? "icon-white" : "";
?>
<ul class="nav nav-list">
    <li class="nav-header">Menu</li>
    <li class="<?php echo $hrefclass['home']; ?>"><a href="?home"><i class="icon-home <?php echo $iconclass['home']; ?>"></i> Home</a></li>
    <li class="<?php echo $hrefclass['profile']; ?>"><a href="?profile&personal"><i class="icon-user <?php echo $iconclass['profile']; ?>"></i> Profile</a></li>
    <li class="<?php echo $hrefclass['create']; ?>"><a href="?create"><i class="icon-film <?php echo $iconclass['create']; ?>"></i> Create movienight</a></li>
    <!--<li class="<?php echo $hrefclass['friends']; ?>"><a href="?friends"><i class="icon-star <?php echo $iconclass['friends']; ?>"></i> Friends</a></li>-->
    <!--<li class="<?php echo $hrefclass['notifications']; ?>"><a href="?notifications"><i class="icon-flag <?php echo $iconclass['notifications']; ?>"></i> Notifications</a></li>-->
    <li class="<?php echo $hrefclass['events']; ?>"><a href="?events">
		<i class="icon-calendar" <?php echo $iconclass['events']; ?>></i> Events
		<?php
			if ($notifications > 0 && CURR_PAGE != "events") {
				echo '<span class="badge badge-success" style="display: inline-block; height: 11px; font-size: 12px;">'.$notifications.'</span>';
			}
		?></a>
	</li>
</ul>